package com.it.dao;

import com.it.domain.VIP_Management;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VIPDao {

    /**
     * 存储会员信息
     * @param vipManagement
     */
    @Insert("insert into vip_management (name,accountnumber,contact,integral) values (#{name},#{accountnumber},#{contact},#{integral})")
    void saveVIPer(VIP_Management vipManagement);

    /**
     * 查询会员信息
     * @return
     */
    @Select("SELECT * FROM vip_management")
    List<VIP_Management> FindAllVIP();

    /**
     * 根据id查询
     * @return
     */
    @Select("SELECT * FROM vip_management WHERE id = #{id}")
    List<VIP_Management> FindById(int id);

    /**
     * 根据id删除用户
     * @param id
     */
    @Delete("DELETE FROM vip_management WHERE id = #{id}")
    void delVip(int id);

    /**
     * 根据id修改信息
     * @param vipManagement
     * @param
     */
    @Update("UPDATE vip_management SET NAME = #{name},accountnumber=#{accountnumber},contact=#{contact},integral=#{integral} WHERE id = #{id}")
    void changeVip(VIP_Management vipManagement);

    /**
     * 模糊查询
     * @param name
     */
    @Select("SELECT * FROM vip_management WHERE NAME LIKE concat('%',#{name},'%')")
    List<VIP_Management> FindByName(String name);
}
